package com.wzy.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 捕获 无权限异常
     * @param request
     * @param ex
     * @return
     */
    @ExceptionHandler(value = AuthorizationException.class)
    public Object exceptionHandler(HttpServletRequest request, Exception ex){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("403");
        return mv;
    }
}
